home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++ FAQ Reference 1.0 / C++ FAQ Reference 1.0.rsrc / TEXT_932.txt < prev    next >
Encoding:
Text File  |  1993-06-30  |  958 b   |  11 lines

  1. A const member function is a promise to the caller not to change the object. Put the word 'const' after the member function's signature; ex:
  2.     class X {
  3.       //...
  4.       void f() const;
  5.     };
  6.  
  7. Some programmers feel this should be a signal to the compiler that the raw bits of the object's 'struct' aren't going to change, others feel it means the *abstract* (client-visible) state of the object isn't going to change.  C++ compilers aren't allowed to assume the bitwise const, since a non-const alias could exist which could modify the state of the object (gluing a 'const' ptr to an object doesn't promise the object won't change; it only promises that the object won't change **via that pointer**).
  8.  
  9. I talked to Jonathan Shopiro at the C++AtWork conference, and he confirmed that the above view has been ratified by the ANSI-C++ standards board.  This doesn't make it a 'perfect' view, but it will make it 'the standard' view.
  10.  
  11. See the next few questions for more.